package com.it.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.it.entity.SysUser;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 */
@Repository
public interface SysUserMapper extends BaseMapper<SysUser> {
    
    @Select("SELECT DISTINCT rm.menu_id FROM sys_user_role ur LEFT JOIN `sys_role_menu` rm ON rm.role_id = ur.role_id WHERE ur.user_id = #{userId};")
    List<Long> getNavMenuIds(Long userId);
    
    @Select("SELECT DISTINCT su.* FROM sys_user_role ur LEFT JOIN `sys_role_menu` rm ON rm.role_id = ur.role_id LEFT JOIN `sys_user` su ON su.id = ur.user_id WHERE rm.menu_id = #{menuId};")
    List<SysUser> listByMenuId(Long menuId);
}
